import { mapGetters } from 'vuex'
export default {
  computed:{
    ...mapGetters('m_cart', ['total'])
  },
  onShow(){
    this.setBadge()
  },
  methods:{
    setBadge(){
      if (this.total <= 0) return
      uni.setTabBarBadge({
        index: 2, // 索引
        text: this.total + '' // text 的值必须是字符串，不能是数字
      })
    }
  },
  watch: {
    total:{
      handler() {
        this.setBadge()
      },
      immediate: true
    }
  }
}